<html>
<head><meta charset="utf-8"><title>Emacs: right syntax for appending to lsp-file-watch-ignored · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Emacs.3A.20right.20syntax.20for.20appending.20to.20lsp-file-watch-ignored.html">Emacs: right syntax for appending to lsp-file-watch-ignored</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="204301856"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Emacs%3A%20right%20syntax%20for%20appending%20to%20lsp-file-watch-ignored/near/204301856" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> apiraino <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Emacs.3A.20right.20syntax.20for.20appending.20to.20lsp-file-watch-ignored.html#204301856">(Jul 18 2020 at 14:05)</a>:</h4>
<p>hi, I'd like to add two more directories to the ignorelist of files watched: <code>tests</code> and <code>bench</code>.</p>
<p>I tried various syntax combinations to append these values to the <a href="https://github.com/emacs-lsp/lsp-mode/blob/52d5c941630ededd30b3e75c72e10d04b2a1abdb/lsp-mode.el#L507">plist defined</a> in lsp-mode.el but I fail, ex.:<br>
<code>(setq lsp-file-watch-ignored "bench\\/")</code></p>
<p>gives me this error when LSp starts on that project:<br>
<code>Error processing message (wrong-type-argument listp "bench\\/$")</code></p>
<p>a little help? :)</p>



<a name="204302745"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Emacs%3A%20right%20syntax%20for%20appending%20to%20lsp-file-watch-ignored/near/204302745" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Emacs.3A.20right.20syntax.20for.20appending.20to.20lsp-file-watch-ignored.html#204302745">(Jul 18 2020 at 14:33)</a>:</h4>
<p>probably something like</p>
<div class="codehilite"><pre><span></span><code><span class="p">(</span><span class="nv">add-to-list</span> <span class="ss">&#39;lsp-file-watch-ignored</span> <span class="s">&quot;bench\\/&quot;</span><span class="p">)</span>
</code></pre></div>


<p>but I also assume the regex should rather be something like <code>"[/\\\\]bench$"</code>, judging from the other examples</p>



<a name="204302788"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Emacs%3A%20right%20syntax%20for%20appending%20to%20lsp-file-watch-ignored/near/204302788" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Emacs.3A.20right.20syntax.20for.20appending.20to.20lsp-file-watch-ignored.html#204302788">(Jul 18 2020 at 14:34)</a>:</h4>
<p>but also, why would you want to ignore tests and bench?</p>



<a name="204303371"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Emacs%3A%20right%20syntax%20for%20appending%20to%20lsp-file-watch-ignored/near/204303371" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> apiraino <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Emacs.3A.20right.20syntax.20for.20appending.20to.20lsp-file-watch-ignored.html#204303371">(Jul 18 2020 at 14:50)</a>:</h4>
<p>hey thanks! but I get another error<br>
<code>Error (use-package): lsp-mode/:init: Symbol’s value as variable is void: lsp-file-watch-ignored</code><br>
I wonder if it possible actually to customize it. I feel like this is not yet supported <span aria-label="thinking" class="emoji emoji-1f914" role="img" title="thinking">:thinking:</span> it's not even documented</p>
<p>I'm trying to ignore those dirs because they contains a lot of junk related to the project but not to my rust code :)<br>
(I still have to tidy up a bit)</p>



<a name="204303644"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Emacs%3A%20right%20syntax%20for%20appending%20to%20lsp-file-watch-ignored/near/204303644" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Emacs.3A.20right.20syntax.20for.20appending.20to.20lsp-file-watch-ignored.html#204303644">(Jul 18 2020 at 14:58)</a>:</h4>
<p>it's a defcustom, so it's customizable. I guess your code gets called before lsp-mode is loaded; you may need to do it in a different section in the use-package declaration</p>



<a name="204303738"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Emacs%3A%20right%20syntax%20for%20appending%20to%20lsp-file-watch-ignored/near/204303738" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> apiraino <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Emacs.3A.20right.20syntax.20for.20appending.20to.20lsp-file-watch-ignored.html#204303738">(Jul 18 2020 at 15:00)</a>:</h4>
<p>uhm ok I see. I'll try to figure it out later. thanks again <span aria-label="thumbs up" class="emoji emoji-1f44d" role="img" title="thumbs up">:thumbs_up:</span></p>



<a name="205219705"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Emacs%3A%20right%20syntax%20for%20appending%20to%20lsp-file-watch-ignored/near/205219705" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> apiraino <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Emacs.3A.20right.20syntax.20for.20appending.20to.20lsp-file-watch-ignored.html#205219705">(Jul 28 2020 at 10:27)</a>:</h4>
<p>ok <span class="user-mention" data-user-id="129457">@Florian Diebold</span> I <em>think</em> I have sorted this out. I use <code>use-package</code> so I checked again their docs first</p>
<p>Before I had</p>
<div class="codehilite"><pre><span></span><code>(use-package lsp-mode
  :init
  (global-set-key (kbd &quot;C-c .&quot;) &#39;lsp-find-definition)
  (global-set-key (kbd &quot;C-c ,&quot;) &#39;pop-tag-mark)
  ... many (setq) ...
  (add-to-list ....)

  (add-hook ....)

  :hook ((rust-mode . lsp))
  :commands lsp)
</code></pre></div>



<a name="205219721"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Emacs%3A%20right%20syntax%20for%20appending%20to%20lsp-file-watch-ignored/near/205219721" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> apiraino <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Emacs.3A.20right.20syntax.20for.20appending.20to.20lsp-file-watch-ignored.html#205219721">(Jul 28 2020 at 10:27)</a>:</h4>
<p>Then I took you hint and moved the <code>add-to-list</code> statement into the <code>:config</code> section</p>
<div class="codehilite"><pre><span></span><code>(use-package lsp-mode
  :init
  (global-set-key (kbd &quot;C-c .&quot;) &#39;lsp-find-definition)
  (global-set-key (kbd &quot;C-c ,&quot;) &#39;pop-tag-mark)
  ... many (setq) ...

  : config
  (add-to-list ....)

  (add-hook ....)

  :hook ((rust-mode . lsp))
  :commands lsp)
</code></pre></div>



<a name="205219777"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Emacs%3A%20right%20syntax%20for%20appending%20to%20lsp-file-watch-ignored/near/205219777" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> apiraino <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Emacs.3A.20right.20syntax.20for.20appending.20to.20lsp-file-watch-ignored.html#205219777">(Jul 28 2020 at 10:28)</a>:</h4>
<p>seems that fixed, the warning does not show up anymore. But I'm not sure I did the right thing :)</p>



<a name="205220068"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Emacs%3A%20right%20syntax%20for%20appending%20to%20lsp-file-watch-ignored/near/205220068" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> apiraino <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Emacs.3A.20right.20syntax.20for.20appending.20to.20lsp-file-watch-ignored.html#205220068">(Jul 28 2020 at 10:32)</a>:</h4>
<p>makes sense the above?</p>



<a name="205220394"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Emacs%3A%20right%20syntax%20for%20appending%20to%20lsp-file-watch-ignored/near/205220394" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Emacs.3A.20right.20syntax.20for.20appending.20to.20lsp-file-watch-ignored.html#205220394">(Jul 28 2020 at 10:36)</a>:</h4>
<p>that's what I was imagining <span aria-label="+1" class="emoji emoji-1f44d" role="img" title="+1">:+1:</span></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>